//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Collections.Generic;
using OpenLS.Core.Serialization;

namespace OpenLS.Chart
{
    internal sealed class CannonicalStringReference : StringReference
    {
        private string _formula;
        private StringData _stringData;

        public override string Formula
        {
            get { return _formula; }
        }

        public override IEnumerable<StringValue> StringValues
        {
            get { throw new NotImplementedException(); }
        }

        protected override void ReadXmlCore(ReadContext context)
        {
            using (ReadContext c = context.Read("strRef"))
            {
                _formula = c.ReadElementString("f");

                _stringData = c.ReadOptionalElementAs<StringData>("strCache");
                Extension = c.ReadOptionalElement<ExtensionElement>("extLst");
            }
        }

        protected override void WriteData(WriteContext context)
        {
            context.WriteOptionalElementAs(_stringData, "strCache");

        }
    }
}